package Operation;

import book.Book;
import book.Bookshelf;

import java.util.Scanner;

public class search implements IoOperation {
    @Override
    public void work(Bookshelf bookshelf){
        System.out.println("正在查找图书，请输入书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int current = bookshelf.number;
        for (int i = 0; i < current; i++){
            Book book = bookshelf.getBooks(i);
            if (book.getName().equals(name)){
                System.out.println("找到这本书！！");
                System.out.println(book);
                return;
            }

        }
        System.out.println("这里没有你要找的书！！");
    }
}
